﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;


namespace TheQuest
{
    class Bat: Enemy
    {
        public Bat(Game game, Point location)
            : base(game, location, 6)
        {
            //no need for subclass constructor; the base class handles everything.
        }
        public override void Move(Random random)
        {
            if (HitPoints > 0)
            {
                if (random.Next(2) == 0)
                {
                    base.Move(FindPlayerDirection(game.PlayerLocation), game.Bounduaries);
                }
                else
                { 
                    Direction directionToMove;
                    switch (random.Next(3))
                    {
                        case 0:
                            directionToMove = Direction.Up;                            
                            break;
                        case 1:
                            directionToMove = Direction.Down;
                            break;
                        case 2:
                            directionToMove = Direction.Left;
                            break;
                        default:
                            directionToMove = Direction.Right;
                            break;
                    }
                    base.location = Move(directionToMove, game.Bounduaries);
                }
                if (NearPlayer())
                {
                    game.HitPlayer(2, random);
                }
            }
        }
    }
}
